<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Community extends Model
{
    protected $fillable = ['province','provincename','region','regionname','area','areaname','town_id','town','metro_id','metro_station_id',
        'title','address','year','map','longitude','latitude','dealnum','feature','thumb','images','content',
        'build_type','age_limit','cover_area','build_area','volume_rate','green_rate','plan_num','park_place','pm_type','pmc',
        'pm_fee','developer','seo_title','seo_keywords','seo_description','status'
        ];

    //小区下所有的二手房
    public function handroom()
    {
        return $this->hasMany('App\Models\Handroom');
    }

    //小区下所有的出租房
    public function rentalhouse()
    {
        return $this->hasMany('App\Models\Rentalhouse');
    }

    public function attribute()
    {
        return $this->belongsTo('App\Models\Attribute','pm_type','id');
    }

    public function community_data()
    {
        return $this->hasMany('App\Models\CommunityData');
    }

    // 格式化images字段
    public function getImagesAttribute($value)
    {
        return unserialize($value);
    }

}
